﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MusicLibraryGUI
{
    public abstract class AudioRecord
    {
        protected string _fileName;
        protected double _length = 0.0;
        private readonly int _bitRate = 320;
        private readonly string _format = "MP3";
        
        public AudioRecord(string filename = "File01")
        {
            this._fileName = filename;
        }

        public AudioRecord(string filename, double length)
        {
            this._fileName = filename;
            this._length = length;
        }

        public AudioRecord(string filename, double length, int bitrate, string format)
        {
            this._fileName = filename;
            this._length = length;
            this._bitRate = bitrate;
            this._format = format;
        }

        public abstract string Info();

        public double Length()
        {
            return this._length;
        }

        public int BitRate()
        {
            return this._bitRate;
        }

        public string Format()
        {
            return this._format;
        }
    }

    public class MusicTrack : AudioRecord
    {
        public string Title;
        public int Number;
        public int Year;

        public MusicTrack(string title, double length = 0.0, string filename = "MusicTrack01") : base(filename, length)
        {
            this.Title = title;
        }

        public string FileName
        {
            get { return this._fileName; }
            set { this._fileName = value; }
        }

        public override string Info()
        {
            return this.Title + " - MusicTrack";
        }
    }

    public class Podcast : AudioRecord
    {
        public string Author;
        public string Theme;
        public string Tag;

        public string FileName
        {
            get { return this._fileName; }
            set { this._fileName = value; }
        }

        public Podcast(string author, string theme = "PodcastTheme01", double length = 0.0, string filename = "Podcast01") : base(filename, length)
        {
            this.Author = author;
            this.Theme = theme;
        }

        public override string Info()
        {
            return this.Author + " - " + this.Theme + " - Podcast";
        }
    }

    public class Song : MusicTrack
    {
        public string Artist;
        public string Genre;
        public string Album;

        public Song (string artist, string title = "SongTitle01", double length = 0.0, string filename = "Song01") : base(title, length, filename)
        {
            this.Artist = artist;
        }

        public override string Info()
        {
            return this.Artist + " - " + this.Title + " - Song";
        }
    }

    public class Classic : MusicTrack
    {
        public string Composer;
        public string Instrument = "Violin";

        public Classic(string composer, string title = "ClassicTitle01", double length = 0.0, string filename = "Classic01") : base(title, length, filename)
        {
            this.Composer = composer;
        }
        public override string Info()
        {
            return this.Composer + " - " + this.Title + " - Classic Composition";
        }

    }

    public abstract class IAudioRecordFactory
    {
        public virtual AudioRecord CreateRecord()
        {
            throw new NotImplementedException();
        }
        public virtual AudioRecord CreateRecord(string title, double length)
        {
            throw new NotImplementedException();
        }
        public virtual AudioRecord CreateRecord(string author, string theme, double length)
        {
            throw new NotImplementedException();
        }
    }

    public class MusicTrackFactory : IAudioRecordFactory
    {
        public override AudioRecord CreateRecord(string title, double length)
        {
            return new MusicTrack(title, length);
        }
    }

    public class PodcastFactory : IAudioRecordFactory
    {
        public override AudioRecord CreateRecord(string author, string theme, double length)
        {
            return new Podcast(author, theme, length);
        }
    }

    public abstract class IMusicTrackFactory
    {
        public virtual MusicTrack CreateMusicTrack()
        {
            throw new NotImplementedException();
        }
        
        public virtual MusicTrack CreateMusicTrack(string artist, string title, double duration)
        {
            throw new NotImplementedException();
        }
    }

    public class SongFactory : IMusicTrackFactory
    {
        public override MusicTrack CreateMusicTrack(string artist, string title, double length)
        {
            return new Song(artist, title, length);
        }
    }

    public class ClassicFactory : IMusicTrackFactory
    {
        public override MusicTrack CreateMusicTrack(string composer, string title, double length)
        {
            return new Classic(composer, title, length);
        }
    }

}
